package com.example.demo.common.utils;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author ccubee
 * @since 20-9-1 21:39
 */
@Configuration
@ConditionalOnClass(RedisTemplate.class)
public class RedisConfig {

    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){

        RedisTemplate<String, Object> template = new RedisTemplate<>();

        // 配置具体的序列化方式
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }
}
